//
//  ZZXstrategryTableViewCell.m
//  Travel
//
//  Created by dllo on 15/11/30.
//  Copyright © 2015年 doll. All rights reserved.
//

#import "ZZXstrategryTableViewCell.h"
#import "UIImageView+WebCache.h"


@interface ZZXstrategryTableViewCell ()
@property (nonatomic, strong)UIImageView *img;
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UILabel *subTitleLabel;
@property (nonatomic, strong)UILabel *descripeLabel;



@end

@implementation ZZXstrategryTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView
{
    self.img = [[UIImageView alloc]init];
    [self.contentView addSubview:self.img];
    self.img.contentMode = UIViewContentModeScaleAspectFill;
    self.img.clipsToBounds = YES;
    self.img.layer.cornerRadius = 8;
    
  
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textColor = [UIColor colorWithRed:0.97 green:0.95 blue:0.91 alpha:1];
    self.titleLabel.shadowColor = [UIColor blackColor];
    self.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
       [self.img addSubview:self.titleLabel];

    
    
    self.subTitleLabel = [[UILabel alloc]init];
    self.subTitleLabel.textColor = [UIColor colorWithRed:0.97 green:0.95 blue:0.91 alpha:1];
    self.subTitleLabel.shadowColor = [UIColor blackColor];
    self.subTitleLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
    [self.img addSubview:self.subTitleLabel];

    
    
    self.descripeLabel = [[UILabel alloc]init];
    self.descripeLabel.textColor = [UIColor colorWithRed:0.97 green:0.95 blue:0.91 alpha:1];
    self.descripeLabel.shadowColor = [UIColor blackColor];
    self.descripeLabel.font = [UIFont fontWithName:@"Helvetica" size:13];
    [self.img addSubview:self.descripeLabel];
    
    
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    //夜间模式
    if ([[NSUserDefaults standardUserDefaults]boolForKey:@"isNight"]) {
        self.contentView.backgroundColor = [UIColor colorWithRed:0.28 green:0.28 blue:0.28 alpha:1];
    }else
    {
        self.contentView.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
    }
    self.img.frame = CGRectMake(0, 0, WIDTH - 20, WIDTH / 3 - 10);
    self.titleLabel.frame = CGRectMake(10, self.img.frame.size.height / 2 - 10 , WIDTH - 10, 20);
    self.subTitleLabel.frame = CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 20, WIDTH - 20, 15);
}

- (void)setGuide:(ZZXstrategryModel *)guide
{
     _guide = guide;
        self.titleLabel.text = self.guide.name;
    if (!self.guide.name) {
        self.titleLabel.text = self.guide.title;
    }
    self.subTitleLabel.text = guide.describe;
    NSString *str = [NSString stringWithFormat:@"%@%@%@", guide.picdomain,@"upload/",guide.coverpic];
    [self.img sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"load.png"]];
    
    
}







- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
